<?php
namespace App\Http\Routes;

use Illuminate\Contracts\Routing\Registrar;

class webRoutes
{
    public function map(Registrar $router)
    {
        $prefix = "admin";

        $router->get($prefix.'/login','Admin\LoginController@index');   //登录
        $router->get($prefix.'/login/do', 'Admin\LoginController@login'); //登录操作

        $router->group(['middleware' => ['admin.service'], 'prefix'=>$prefix], function($router){
            $router->get('/dashboard/{dashboard}', 'Admin\AdminController@dashboard');
            //退出登录
            $router->get('/logout', 'Admin\LoginController@logout');
            //首页
            $router->get('/main', 'Admin\AdminController@main');
            $router->get('/index', 'Admin\AdminController@index');
            $router->get('/index', 'Admin\AdminController@index');
            $router->get('/user', 'Admin\MainController@index');
            $router->get('/user/search', 'Admin\MainController@search');

            //权限路由
            $this->permission($router);
            //角色路由
            $this->role($router);
            //用户路由
            $this->user($router);
            //日志查看
            $this->record($router);
            //房费设置
            $this->room($router);

            //公共路由（Excel）
            $this->common($router);
        });
    }

    /*
     * 权限路由
     * @param $router
     */
    public function permission($router){
        //权限
        $router->get('/permission', 'Admin\System\PermissionController@index');
        $router->get('/permission/search', 'Admin\System\PermissionController@search');
        $router->post('/permission/store', 'Admin\System\PermissionController@store');
        $router->get('/permission/detail/{id}', 'Admin\System\PermissionController@get');
        $router->get('/permission/delete/{id}', 'Admin\System\PermissionController@delete');
        $router->get('/permission/out', 'Admin\System\PermissionController@out');

        //权限组
        $router->get('/permission/group', 'Admin\System\PermissionGroupController@index');
        $router->get('/permission/group/search', 'Admin\System\PermissionGroupController@search');
        $router->get('/permission/group/{id}', 'Admin\System\PermissionGroupController@get');
        $router->post('/permission/group/store', 'Admin\System\PermissionGroupController@store');
    }

    /*
     * 角色路由
     * @param $router
     */
    public function role($router){

        //角色
        $router->get('/role', 'Admin\System\RoleController@index');
        $router->get('/role/search', 'Admin\System\RoleController@search');
        $router->get('/role/permission/{id}', 'Admin\System\RoleController@permission');
        $router->get('/role/store/permission', 'Admin\System\RoleController@storePermission');
        $router->get('/role/detail/{id}', 'Admin\System\RoleController@get');   //   单个角色信息
        $router->get('/role/delete/{id}', 'Admin\System\RoleController@delete');
        $router->post('/role/store', 'Admin\System\RoleController@store');


        //角色组
        $router->get('/role/group', 'Admin\System\RoleGroupController@index');
        $router->get('/role/group/search', 'Admin\System\RoleGroupController@search');
        $router->get('/role/group/{id}', 'Admin\System\RoleGroupController@get');
        $router->get('/role/group/delete/{id}', 'Admin\System\RoleGroupController@delete');
        $router->post('/role/group/store', 'Admin\System\RoleGroupController@store');

    }

    /*
     * 用户路由
     * @param $router
     */
    public function user($router){

        //用户
        $router->get('usr', 'Admin\System\UserController@index');
        $router->post('/usr/store','Admin\System\UserController@store');              //增加/编辑员工
        $router->get('/usr/search', 'Admin\System\UserController@search');            //查询
        $router->get('/usr/delete/{id}', 'Admin\System\UserController@delete');   //删除用户
        $router->get('/usr/detail/{id}', 'Admin\System\UserController@get');          //得到单一用户信息
        $router->post('/usr/change/pwd', 'Admin\System\UserController@editPwd');          //修改密码

        //部门
        $router->post('/department/store','Admin\System\DepartmentController@store');       //保存部门信息
        $router->get('/department/get', 'Admin\System\DepartmentController@get');        //查询部门信息
        $router->get('/department/delete/{id}', 'Admin\System\DepartmentController@delete');      //删除部门
        $router->get('/department/search', 'Admin\System\DepartmentController@search');    //查询
        $router->get('/department/sub/{id}', 'Admin\System\DepartmentController@get_sub_department');   //根据找到下属部门
    }
    /*
     * 用户查看日志
     * @param $router
     */
    public function record($router){

        //用户
        $router->get('/record', 'Admin\RecordController@lookindex');
        $router->get('/searchRecord', 'Admin\RecordController@searchRecord');

    }
    /*
     * 房费设置
     * @param $router
     */
    public function room($router){
        $router->get('/room', 'Admin\RoomController@index');
        $router->get('/room/save/{num}', 'Admin\RoomController@save');
        $router->get('/statistics', 'Admin\StatisticsController@index');
        $router->get('/statistics/search', 'Admin\StatisticsController@search');
        $router->get('/statistics/details/{id}', 'Admin\StatisticsController@details');
        $router->get('/statistics/details/search', 'Admin\StatisticsController@details_search');
        $router->get('/statistics/change/{id}', 'Admin\StatisticsController@change');
        $router->get('/statistics/exchange/search', 'Admin\StatisticsController@change_search');
    }

    public function common($router){
        $router->get('/excel/export/{id}', 'Admin\Common\ExcelController@index');
    }

}

